<!DOCTYPE html>
<html style="height: 100%">
<head>
    <meta charset="utf-8"><link rel="icon" href="img/icon.jpg">
    <meta name="易农" content="width=device-width, initial-scale=1">
    <meta charset="utf-8">
    <title>{{title}}</title>
</head>
<link rel="stylesheet" href="https://unpkg.com/purecss@1.0.0/build/base-min.css">
<link rel="stylesheet" type="text/css" href="css/index.css">
<body style="height: 100%; margin: 0">

<header class="head">
    <h3 class="head_button" ><a href="/">首页</a></h3>
    <h3 class="head_button"><a style="background-color: gray" href="/hurt">小麦病虫害</a></h3>
    <h3 class="head_button" ><a href="/mostLike_addr">最受欢迎农产品价格比较</a></h3>
    <h3 class="head_button" ><a href="/line">农业总产值预测</a></h3>
    <h3 class="head_button" ><a href="/line_product">历史农产品价格</a></h3>
</header>
<section  id="content" style="color: #00BFFF;padding: 1% 30%;margin-top: 5%">

</section>

<!--<h1>{{content}}</h1>-->
</body>

<script src="https://code.bdstatic.com/npm/jquery@1.12.4/dist/jquery.min.js"></script>
<script type="text/javascript">
    localStorage.clear();
    // setTimeout(sheldue,10000);
    // alert("2021-5-7 可能会发生的病虫害和相应的药物");
//原生js发送Ajax
function httpPost(url,param) {
    var xhr = new XMLHttpRequest();
    xhr.open('POST', url,true);
    xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xhr.send(param);
    xhr.onreadystatechange = function () {
        if (xhr.readyState == 4 && xhr.status == 200) {
            console.log(localStorage.getItem(url)!= null);
            console.log(localStorage.getItem(url) == xhr.responseText);
            var s = new String(xhr.responseText);
            if(localStorage.getItem(url)!= null && localStorage.getItem(url) == s ){
                return;
            }else{
                localStorage.setItem(url,s);
            }
            console.log(xhr.responseText);
            var r = JSON.parse(xhr.responseText);
            console.log(r);
            var mm = {};
            if(r && r.rows && r.rows.length > 0){
                for(var i in r.rows){
                    var item = r.rows[i];
                    var html = "易发"

                        if(verify(item.wsGrowthStage)){
                            html = html +"："+item.wsGrowthStage+"，"
                        }else if(verify(item.giGrowthStage)){
                            html = html +"："+item.giGrowthStage+"，"
                        }else if(verify(item.wseGrowthStage)){
                            html = html +"："+item.wseGrowthStage+"，"
                        }
                        if(verify(item.wsSurveyData)){
                            html = html +item.wsInvestigationContent +":" +item.wsSurveyData+",";
                        }else if(verify(item.giSurveyData)){
                            html = html +item.giInvestigationContent +":" +item.giSurveyData+",";
                        }else if(verify(item.wseSurveyData)){
                            html = html +item.wseInvestigationContent +":" +item.wseSurveyData+",";
                        }

                    if(verify(item.giInvestigationStartTime)){
                        html = html +"时间："+item.giInvestigationStartTime+" - "+item.giEndtimeOfInvestigation + ","
                    }else if(verify(item.wsInvestigationStartTime)){
                        html = html +"时间："+item.wsInvestigationStartTime+" - "+item.wsEndtimeOfInvestigation + ","
                    }else if(verify(item.wseInvestigationStartTime)){
                        html = html +"时间："+item.wseInvestigationStartTime+" - "+item.wseEndtimeOfInvestigation + ","
                    }

                     if(verify(item.giLocationOfInvestigation)){
                         html = html  +"地点："+item.giLocationOfInvestigation+"。"
                     }else if(verify(item.wsLocationOfInvestigation)){
                         html = html+"地点："+item.wsLocationOfInvestigation+"。"
                     }else if(verify(item.wseLocationOfInvestigation)){
                         html = html+"地点："+item.wseLocationOfInvestigation+"。"
                     }
                    alert(html);
                    // setTimeout(function () {
                    //     //内容3秒后执行
                    //     showTips(html,2000,1);
                    // }, 3000);
                    // showTips(html,2000,1);
                    console.log(html);
                    var h = document.createElement("h4");
                    h.id = "h";
                    h.innerHTML = html;
                    document.getElementById("content").appendChild(h);
                }
            }else{
                document.getElementById("content").innerHTML = "<h3>近期没有病虫害!</h3>";
            }
        }
    };
}
    // var params = [
    //     'method=/ruoyi-admin/biz/eyespot/list&name="+1',
    //     'method=/ruoyi-admin/biz/isease/list&name="+1',
    //     'method=/ruoyi-admin/biz/spider/list&name="+1'
    // ]
    var params = [
        'method=/biz/eyespot/selectList',
        'method=/biz/isease/selectList',
        'method=/biz/spider/selectList'
    ]
    function f() {
        document.getElementById("content").innerHTML = "";
        for(var i in params){
            httpPost('/api',params[i]);
        }
    }
    function sleep(millisecond) {
        return new Promise(resolve => {
            setTimeout(() => {
                resolve()
            }, millisecond)
        })
    }

    function verify(p) {
        if(p != null){
            // console.log(p);
            return true;
        }
        return false;
    }
    function sheldue() {
        self.setInterval(f,10000);
    }
    //contetn为要显示的内容
    //height为离窗口顶部的距离
    //time为多少秒后关闭的时间，单位为秒
    function showTips( content, height, time ){
        //窗口的宽度
        var windowWidth  = $(window).width();
        var tipsDiv = '<div class="tipsClass">' + content + '</div>';

        $( 'body' ).append( tipsDiv );
        $( 'div.tipsClass' ).css({
            'top'       : height + 'px',
            'left'      : ( windowWidth / 2 ) - 350/2 + 'px',
            'position'  : 'absolute',
            'padding'   : '3px 5px',
            'background': 'gray',
            'font-size' : 12 + 'px',
            'margin'    : '0 auto',
            'text-align': 'center',
            'width'     : '350px',
            'height'    : 'auto',
            'color'     : '#fff',
            'opacity'   : '0.8'
        }).show();
        setTimeout( function(){$( 'div.tipsClass' ).fadeOut();}, ( time * 1000 ) );
    }
    //调用该方法时：
    // showTips("的凯撒奖打卡机京东卡时间段卡双节快乐就",200,1);
    f();
    sheldue();



</script>
</html>   



